﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace QLTSCD
{
    public partial class frmPhieuNhap : DevComponents.DotNetBar.Office2007Form
    {
        public frmPhieuNhap()
        {
            InitializeComponent();
        }
#region "Event"

        private void frmPhieuNhap_Load(object sender, EventArgs e)
        {
            //Load danh sách nhà cung cấp
            cbxNCC_Load();
            //Load danh sách phiếu nhập
            grvPhieuNhap_Load();
        }

#endregion

#region "Common Function"
        //Load danh sách nhà cung cấp
        private void cbxNCC_Load()
        {
            QLTSCDDataContext db = new QLTSCDDataContext();
            var listNCC = from ncc in db.NhaCungCaps
                          select ncc;
            cbxNCC.DataSource = listNCC;
            cbxNCC.DisplayMember = "Ten";
            cbxNCC.ValueMember = "MaNhaCungCap";
        }

        //Load danh sách Phiếu nhập
        private void grvPhieuNhap_Load()
        {
            QLTSCDDataContext db = new QLTSCDDataContext();
            var listPN = from pn in db.PhieuNhaps
                         join ncc in db.NhaCungCaps
                         on pn.MaNhaCungCap equals ncc.MaNhaCungCap
                         select new { pn.MaPhieuNhap,pn.MaNhaCungCap,pn.NgayNhap,ncc.Ten};
            grvPhieuNhap.AutoGenerateColumns = false;
            grvPhieuNhap.DataSource = listPN;
            
        }
#endregion
    }
}
